#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 1000000000;
int n,m,L,V;
int d[100005],v[100005],a[100005];
int p[100005];
int dp[100005],l[100005];
int ll = 1,rr = 0;
int q[200005];
void add(int L,int R,int id){
	l[R]=max(l[R],L);
	//cout << " " << L << " " << R << " " << id << endl;
}
int work(){
	ll = 1,rr = 0;
	dp[0]=0;
	for(int i = 1;i<=m+1;i++)dp[i] = inf;
	for(int i = 1;i<=m+1;i++)l[i] = max(l[i],l[i-1]);
	q[++rr] = 0;
	for(int i = 1;i<=m+1;i++){
		while(rr>=ll and q[ll]<l[i-1])++ll;
		dp[i]=dp[q[ll]]+1;
		while(rr>=ll and dp[q[rr]]>=dp[i])--rr;
		q[++rr] = i;
	}
//	for(int i = 1;i<=m+1;i++)cout << l[i] << " ";cout << endl;
//	for(int i = 1;i<=m+1;i++)cout << dp[i] << " ";cout << endl;
	return dp[m+1]-1;
}
void solve(int id){
	int cnt =0 ;
	for(int i = 0;i<=m+1;i++)l[i] = 0;
	cin >> n >> m >> L >> V;

	//cout << " " << n << " " << m << " " << L << " " << V << endl;
	for(int i = 1;i<=n;i++)cin >> d[i] >> v[i] >> a[i];
	for(int i = 1;i<=m;i++)cin >> p[i];
	//if(id!=13)return;
	for(int i = 1;i<=n;i++){
		int pos = lower_bound(p+1,p+1+m,d[i])-p;
	//	cout << " " << pos << " " << p[pos] << " " << d[i] << endl;
		if(pos==m+1)continue;
		if(a[i] == 0){
			if(v[i]>V){
				++cnt;
				add(pos,m,i);
			}
		}else if(a[i]>0){
			int l = pos,r = m;
			int dd = p[m]-d[i],vv = v[i]*v[i]+2*a[i]*dd;
			if(vv<0 or vv<=V*V)continue;
			++cnt;
			while(l<r){
				int mid=l+r>>1;
				int dd = p[mid]-d[i];
				int vv = v[i]*v[i]+2*a[i]*dd;
				if(vv>V*V)r = mid;
				else l = mid+1;
			}
			add(r,m,i);
		}else{
			int l = pos,r = m;
			int dd = p[l]-d[i],vv = v[i]*v[i]+2*a[i]*dd;
	//		cout << " > " << dd << " " << sqrt(vv) << endl;
			if(vv<0 or vv<=V*V)continue;
			++cnt;
			while(l<r){
				int mid = l+r+1>>1;
				int dd = p[mid]-d[i];
				int vv = v[i]*v[i]+2*a[i]*dd;
				if(vv>V*V)l = mid;
				else r = mid-1;
			}
		//	cout << " " << i << " " << pos << endl;
			add(pos,l,i);
		}
	}
	int res = work();
	res = m-res;
	cout << cnt << " " << res << '\n';
}

signed main(){

	//freopen("/home/csps/detect4.in","r",stdin);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t;cin >> t;
//	cout << " " << t << endl;
	for(int i = 1;i<=t;i++)solve(i);
	return 0;
}
/*
g++ detect.cpp -o qwq -std=c++14 -fsanitize=address,undefined

9 10 114934 719
62115 915 -6
44976 920 -17
21788 877 -1
38609 839 -3
44828 982 -8
9713 1000 -109
61421 860 -922
16064 918 -2
33522 989 -11
*/